module V{
    /** 玩家界面 */
    export class PlayerView extends eui.Component{
        /** 当前玩家的椅子号 */
        public chairId:number;

        public constructor(){
            super();
            this.chairId = 65535;
        }

        /** 初始化界面 */
        public init():void{

        }

        /** 游戏开始 */
        public onGameStart(data:any):void{
            
        }

        /** 同步桌子 */
        public onSyncData(data:any):void{
            
        }

        /** 显示玩家 */
        public show():boolean{
            let ov = this.visible;
            if(D.App.table.players[this.chairId]) this.visible = true;
            else this.visible = false;
            //console.log("show", this.chairId, this.visible);
            return ov != this.visible;
        }

        /** 隐藏玩家 */
        public hide():void{
            this.visible = false;
        }

        /** 状态变化 */
        public status():void{

        }

        /** 筹码变化 */
        public changeScore():void{

        }

        /** 显示操作 */
        public showOpt():void{

        }

        /** 隐藏操作 */
        public hideOpt(data:any):void{

        }

        /** 玩家数据对象 */
        public getData():D.PlayerData{
            return D.App.table.players[this.chairId];
        }

        /** 检查是否是自己 */
        public isMe():boolean{
            return D.App.userData.chairID != 65535 && this.chairId == D.App.userData.chairID
        }

        /** 是否正在游戏 */
        public isPlay():boolean{
            return this.visible == true && D.App.table.players[this.chairId] && (D.App.table.players[this.chairId].userStatus == UserStatus.PLAY || D.App.table.players[this.chairId].userStatus == UserStatus.MATCH);
        }
    }
}